home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15068 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: solon.com!not-for-mail
  2. From: News User Id <news@eskimo.com>
  3. Newsgroups: comp.lang.c.moderated,comp.lang.c
  4. Subject: Re: fflush(stdin) - not guaranteed to work?
  5. Date: 16 Apr 1996 20:44:23 -0500
  6. Organization: schmorganization
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4l1idn$pvs@solutions.solon.com>
  10. References: <4ksjpn$rjt@solutions.solon.com> <4ku3id$53h@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12. X-Nntp-Posting-Host: eskimo.com
  13.  
  14. In article <4ku3id$53h@solutions.solon.com>, c2a192@ugrad.cs.ubc.ca
  15. (Kazimir Kylheku) writes:
  16. > In article <4ksjpn$rjt@solutions.solon.com>,
  17. > Himanshu Gohel <gohel@csee.usf.edu> wrote:
  18. >> My question is, why?  Some of my students have written programs using
  19. >> fflush(stdin) hoping it would clear away anything that's in the input
  20. >> buffer before a scanf() statement and apparently it works on some PC
  21. >> based compilers, but when re-compiled on a UNIX system, it does not
  22. >> always work.
  23. > There is a detailed discussion in the comp.lang.c FAQ that
  24. > covers VMS, UNIX and DOS in this respect, as far as I recall.
  25.  
  26. Before anyone goes off and looks and is disappointed (actually,
  27. it's probably too late for that), the only system-specific
  28. question that the comp.lang.c FAQ list answers in that much
  29. detail is, "How do I read one character without waiting for
  30. the RETURN key?".  To the implicit followon question, "If
  31. fflush(stdin) won't work, how *can* I flush the user's typeahead
  32. before issuing a prompt confirming whether I should reformat the
  33. hard drive?", the FAQ list suggests no answer, because I don't
  34. know a good one (other than, your program probably shouldn't be
  35. offering to do that at all).
  36.  
  37.                     Steve Summit
  38.                     scs@eskimo.com
  39.